/**
 # # THIS FILE IS PART OF drug-server PROJECT
 # #
 # MybatisPlusConfig.java - MybatisPlusConfig
 # 
 # THIS PROGRAM IS OPENSOURCE SOFTWARE, IS LICENSED UNDER BSD
 # YOU SHOULD HAVE RECEIVED A COPY OF WTFPL LICENSE
 # 
 # Copyright (c) 2018 Ting Fan
 */
package com.cloudkinto.config;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @program     : drug-server
 * @description : MybatisPlusConfig
 * @author      : Ting Fan
 * @company     : 苏州
 * @create      : 2019-09-19 21:08
 **/
@EnableTransactionManagement
@Configuration
public class MybatisPlusConfig {
    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        // paginationInterceptor.setLimit(你的最大单页限制数量，默认 500 条，小于 0 如 -1 不受限制);
        return paginationInterceptor;
    }

    /**
     * 乐观锁
     * @return
     */
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
        return new OptimisticLockerInterceptor();
    }
}
